package com.bjpowernode.springboot.web;

import com.bjpowernode.springboot.model.Student;
import com.bjpowernode.springboot.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class StudentController {

    @Autowired
    private StudentService studentService;

    @RequestMapping(value = "/student/{id}/{name}/{password}")
    public Object student(@PathVariable("id") Integer id,
                          @PathVariable("name") String name,
                          @PathVariable("password") String password){
        Student student = new Student();
        student.setId(id);
        student.setName(name);
        student.setPassword(password);
        int res = studentService.insert(student);
        return res == 1 ? "数据插入成功" : "数据插入失败";
    }
}
